#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Flash Drive Backup - by Jo", 623, 449, 192, 114)
$lstProfiles = GUICtrlCreateList("", 16, 16, 585, 383)
$btnView = GUICtrlCreateButton("View", 16, 408, 75, 25)
$btnEdit = GUICtrlCreateButton("Edit", 280, 408, 75, 25)
$btnAdd = GUICtrlCreateButton("Add", 528, 408, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

loadIni()

While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $btnView
			$selectedDrive=StringSplit(GUICtrlRead($lstProfiles),",")
			$name = $selectedDrive[1]
			$letter = $selectedDrive[2]
			$incremental = $selectedDrive[3]
			;For $i = 1 To $selectedDrive[0]
			;	MsgBox(0,"",$selectedDrive[$i])
			;Next
		Case $GUI_EVENT_CLOSE
			Exit

	EndSwitch
WEnd


Func loadIni()
	$iniFile = @ScriptDir & "\FlashDriveBackup.cfg"
	$flashDrives = IniReadSectionNames($iniFile)
	For $i = 1 To $flashDrives[0]
		If $flashDrives[$i] == "Setup" Then
			Sleep(1)
		Else
			$name = IniRead($iniFile,$flashDrives[$i],"name","Unknown")
			$letter = IniRead($iniFile,$flashDrives[$i],"letter","Unknown")
			$incremental = IniRead($iniFile,$flashDrives[$i],"incremental",0)
			GUICtrlSetData($lstProfiles, $name & "," & $letter & "," & $incremental & "," & $flashDrives[$i])
		;$ = IniRead($iniFile,$flashDrives[$i],"","Unknown")
		EndIf
	Next
EndFunc